﻿using Coldairarrow.Business.PB;
using Coldairarrow.Entity.DTO;
using Coldairarrow.Entity.PB;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.PB
{
    [Route("/PB/[controller]/[action]")]
    public class PB_ShiftTypeController : BaseApiController
    {
        #region DI

        public PB_ShiftTypeController(IPB_ShiftTypeBusiness pB_ShiftTypeBus)
        {
            _pB_ShiftTypeBus = pB_ShiftTypeBus;
        }

        IPB_ShiftTypeBusiness _pB_ShiftTypeBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<PB_ShiftType>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _pB_ShiftTypeBus.GetDataListAsync(input);
        }
        [HttpPost]
        public async Task<PageResult<PB_ShiftTypeDTO>> GetDataListAsyncDTO(PageInput<ConditionDTO> input)
        {
            return await _pB_ShiftTypeBus.GetDataListAsyncDTO(input);
        }
        [HttpPost]
        public async Task<PageResult<PB_ShiftType>> GetDataListworkid(PageInput<ConditionDTO> input,string workid)
        {
            return await _pB_ShiftTypeBus.GetDataListAsyncworkid(input,workid);
        }

        /// <summary>
        /// 根据生产车间查询白班
        /// </summary>
        /// <param name="input"></param>
        /// <param name="workid"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<PB_ShiftType>> GetDataListAsyncworkidBai(PageInput<ConditionDTO> input, string workid)
        {
            return await _pB_ShiftTypeBus.GetDataListAsyncworkidBai(input, workid);
        }
        [HttpPost]
        public async Task<PageResult<PB_ShiftType>> GetDataListAsyncworkidYe(PageInput<ConditionDTO> input, string workid)
        {
            return await _pB_ShiftTypeBus.GetDataListAsyncworkidYe(input, workid);
        }
        [HttpPost]
        public async Task<PB_ShiftType> GetTheData(IdInputDTO input)
        {
            return await _pB_ShiftTypeBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(PB_ShiftType data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _pB_ShiftTypeBus.AddDataAsync(data);
            }
            else
            {
                await _pB_ShiftTypeBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _pB_ShiftTypeBus.DeleteDataAsync(ids);
        }

        /// <summary>
        /// 获取当前车间下的班别
        /// </summary>
        [HttpPost]
        public async Task<List<PB_ShiftType>> GetWorkShiftType(string WorkShopId) {
            List<PB_ShiftType> pB_ShiftTypes = await _pB_ShiftTypeBus.GetWorkShiftType(WorkShopId);
            return pB_ShiftTypes;
        }
        #endregion
    }
}